package com.dlry.db;

import java.util.List;

import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.dlry.entity.DlLeave;
import com.dlry.entity.DlLeaveflow;
import com.dlry.entity.DlLoginuser;

public interface LeaveFlowRepository extends JpaRepository<DlLeaveflow, Long> {

	Page<DlLeaveflow> findAll(Pageable arg0);

	<S extends DlLeaveflow> long count(Example<S> arg0);

	<S extends DlLeaveflow> boolean exists(Example<S> arg0);

	<S extends DlLeaveflow> Page<S> findAll(Example<S> arg0, Pageable arg1);

	<S extends DlLeaveflow> S findOne(Example<S> arg0);

	long count();

	void delete(DlLeaveflow arg0);

	void delete(Iterable<? extends DlLeaveflow> arg0);

	void delete(Long arg0);

	void deleteAll();

	boolean exists(Long arg0);

	DlLeaveflow findOne(Long arg0);

	<S extends DlLeaveflow> S save(S arg0);

	List<DlLeaveflow> findAll();

	List<DlLeaveflow> findAll(Sort sort);

	List<DlLeaveflow> findAll(Iterable<Long> ids);

	<S extends DlLeaveflow> List<S> save(Iterable<S> entities);

	void flush();

	<S extends DlLeaveflow> S saveAndFlush(S entity);

	<S extends DlLeaveflow> List<S> findAll(Example<S> example);

	<S extends DlLeaveflow> List<S> findAll(Example<S> example, Sort sort);

	@Query("from DlLeaveflow as f where f.dlLeave = ?1")
	List<DlLeaveflow> findFlowByLeave(DlLeave leave);

	@Query(nativeQuery = true, value = "select * from dl_leaveflow as f where f.ltid = ?1")
	List<DlLeaveflow> findFlowByltId(Long ltId);

	@Query(nativeQuery = true, value = "select * from dl_leaveflow as f where f.hid = ?1")
	List<DlLeaveflow> findDlLeaveflowsByHUserIdAndFinishIsTrue(Long hId);

	List<DlLeaveflow> findDlLeaveflowsByHUserAndFinishIsTrue(DlLoginuser hUser);
}
